home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
DYN401.ZIP
/
class
/
intassoc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-16
|
5KB
|
172 lines
/* Copyright (c) 1993-1996 Algorithms Corporation */
/* All rights reserved. */
/* This file automatically generated by dpp - do not edit */
#define DPP_STRATEGY 2
#define DPP_FASTWIDE 0
#line 15 "intassoc.d"
#include <math.h>
#define CLASS IntegerAssociation_c
#define ivType IntegerAssociation_iv_t
#include "generics.h"
object IntegerAssociation_c;
#line 28 "intassoc.c"
typedef struct _IntegerAssociation_iv_t {
int iKey;
object iValue;
} IntegerAssociation_iv_t;
#line 22 "intassoc.d"
cmeth objrtn IntegerAssociation_cm_gNewWithIntObj(object self, int key, object value)
{
object assoc;
ivType *iv;
ChkArgNul(value, 3);
assoc = oSuper(IntegerAssociation_c, gNew, self)(self);
iv = ivPtr(assoc);
iv->iKey = key;
iv->iValue = value;
return assoc;
}
imeth objrtn IntegerAssociation_im_gDeepCopy(object self)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
object nobj;
nobj = oSuper(IntegerAssociation_c, gDeepCopy, self)(self);
ivPtr(nobj)->iValue = iv->iValue ? gDeepCopy(iv->iValue) : NULL;
return nobj;
}
imeth objrtn IntegerAssociation_im_gValue(object self)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
return iv->iValue;
}
imeth objrtn IntegerAssociation_im_gChangeValue(object self, object value)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
object ret;
ChkArgNul(value, 2);
ret = iv->iValue;
iv->iValue = value;
return ret;
}
imeth int IntegerAssociation_im_gIntKey(object self)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
return iv->iKey;
}
imeth objrtn IntegerAssociation_im_gChangeIntKey(object self, int key)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
iv->iKey = key;
return self;
}
imeth objrtn IntegerAssociation_im_gDeepDispose(object self)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
if (iv->iValue)
gDeepDispose(iv->iValue);
return oSuper(IntegerAssociation_c, gDispose, self)(self);
}
imeth objrtn IntegerAssociation_im_gStringRepValue(object self)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
object s, t;
t = iv->iValue ? gStringRepValue(iv->iValue) : gNewWithStr(String, "(null)");
s = vSprintf(String, "( %d, ", iv->iKey);
vBuild(s, NULL, t, " )", NULL);
gDispose(t);
return s;
}
imeth int IntegerAssociation_im_gHash(object self)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
double t;
t = .6125423371 * (unsigned) iv->iKey;
t = t < 0.0 ? -t : t;
return (int) (BIG_INT * (t - floor(t)));
}
imeth int IntegerAssociation_im_gCompare(object self, object arg)
{ IntegerAssociation_iv_t *iv = GetIVs(IntegerAssociation, self);
int sv, ov;
ChkArg(arg, 2);
if ((sv=iv->iKey) < (ov=gIntKey(arg)))
return -1;
else if (sv == ov)
return 0;
else
return 1;
}
#line 125 "intassoc.c"
objrtn IntegerAssociation_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (IntegerAssociation_c) {
LEAVECRITICALSECTION(cs);
return IntegerAssociation_c;
}
INHIBIT_THREADER;
Association_initialize();
if (IntegerAssociation_c) {
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return IntegerAssociation_c;
}
IntegerAssociation_c = gNewClass(Class, "IntegerAssociation", sizeof(IntegerAssociation_iv_t), 0, Association, END);
cMethodFor(IntegerAssociation, gNewWithIntObj, IntegerAssociation_cm_gNewWithIntObj);
iMethodFor(IntegerAssociation, gCompare, IntegerAssociation_im_gCompare);
iMethodFor(IntegerAssociation, gChangeIntKey, IntegerAssociation_im_gChangeIntKey);
iMethodFor(IntegerAssociation, gValue, IntegerAssociation_im_gValue);
iMethodFor(IntegerAssociation, gStringRepValue, IntegerAssociation_im_gStringRepValue);
iMethodFor(IntegerAssociation, gHash, IntegerAssociation_im_gHash);
iMethodFor(IntegerAssociation, gChangeValue, IntegerAssociation_im_gChangeValue);
iMethodFor(IntegerAssociation, gDeepDispose, IntegerAssociation_im_gDeepDispose);
iMethodFor(IntegerAssociation, gDeepCopy, IntegerAssociation_im_gDeepCopy);
iMethodFor(IntegerAssociation, gIntKey, IntegerAssociation_im_gIntKey);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return IntegerAssociation_c;
}